package com.jvyou.driver.service.impl;

import com.jvyou.driver.client.SparkServiceClient;
import com.jvyou.driver.constants.SparkRole;
import com.jvyou.driver.domain.dto.SparkRequestDto;
import com.jvyou.driver.domain.dto.SparkResponseDto;
import com.jvyou.driver.domain.entity.SparkMessage;
import com.jvyou.driver.domain.modal.Result;
import com.jvyou.driver.service.SparkMessageService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Collections;

/**
 * @author 橘柚
 * @since 2024/12/20 12:38
 */
@Service("sparkMessageService")
public class SparkMessageServiceImpl implements SparkMessageService {

    @Resource
    private SparkServiceClient sparkServiceClient;

    @Override
    public Result<String> subjectOneChoice() {
        SparkRequestDto sparkRequestDto = new SparkRequestDto();
        sparkRequestDto.setModel("generalv3.5");
        sparkRequestDto.setUser("jvyou");
        String command = "随机给我一道驾照考试科目一的选择题，返回的内容严格按照以下模板,保留中括号，最后一个中括号里面为答案，且不要有其他多余的回答，模板：[题目内容][A.A选项内容][B.B选项内容][C.C选项内容][D.D选项内容][A]";
        sparkRequestDto.setMessages(Collections.singletonList(new SparkMessage(SparkRole.USER, command)));
        SparkResponseDto sparkResponseDto = sparkServiceClient.chat(sparkRequestDto);
        return Result.okResult(sparkResponseDto.getChoices().get(0).getMessage().getContent());
    }
}
